﻿using System.Collections.Generic;
using UnityEngine;

namespace Gameplay
{
    [CreateAssetMenu(fileName = "NewNormalAttackCombo", menuName = "Skill/NormalAttackCombo")]
    public class NormalAttackCombo:Skill
    {
        public float IntervalTime;

        public List<AudioClip> AudioClips;

        private int _comboCount = 0;
        private float lastTime = 0;//上一次输入时间
        private bool _active = false;

        public override void Use(Character user)
        {
            base.Use(user);
            _animator.SetInteger("ComboCount",_comboCount);
            lastTime = Time.time;
            _comboCount++;
            _active = true;
            if (_comboCount > 2) 
            {
                _comboCount = 0;
            }
        }

        public override void Update()
        {
            if (_active) 
            {
                if (Time.time - lastTime > IntervalTime) 
                {
                    _comboCount = 0;
                    _active = false;
                }
            }
        }
  
        public override void Finish()
        {
       
            _user.Weapon.HitCollider(false);
        }

        public override void Trigger()
        {
            AudioManager.Instance.PlaySound(AudioClips[_comboCount]);
            _user.ParticleManager.PlaySwordTrail(Config.effectVFX,_comboCount);
            _user.Weapon.HitCollider(true);
        }

        
    }
}
